/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
import React, { useState, useEffect } from 'react';
import { Upload, message, Button, Input, Select, Radio, Form, InputNumber, Checkbox, Cascader } from 'antd';
import { If } from 'babel-plugin-jsx-control-statements';
import { UploadOutlined, MinusCircleOutlined } from '@ant-design/icons';
import RequestApi from '@/utils/request';
import { useRequest } from 'ahooks';
import RecordProve from '@/components/image-roate';
import EditorTip from '@/components/admin-rectication-opinions';
import Map from '@/components/XlsxImport';
import BusinessType from '@/utils/BusinessType';
import axios from 'axios';
import css from './index.scss';

export default () => {
	const info = {
		name: 'qq图片.png',
		path: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
	};
	const [form] = Form.useForm();
	const onFinish = (value) => {
		console.log(value);
	};
	const [address, setAddress] = useState();
	useEffect(() => {
		RequestApi.connection('get', `district/getList`).then((response) => {
			const option = [];
			for (let i = 0; i < response.data.length; i += 1) {
				const child = [];
				for (let j = 0; j < response.data[i].sonArea.length; j += 1) {
					child.push({
						value: `${response.data[i].sonArea[j].id}:${response.data[i].sonArea[j].name}`,
						label: response.data[i].sonArea[j].name,
					});
				}
				option.push({
					value: `${response.data[i].id}:${response.data[i].name}`,
					label: response.data[i].name,
					children: child,
				});
			}
			setAddress(option);
		});
	}, []);
	console.log('address', address);
	return (
		<div>
			<RecordProve info={info} />
			<Form onFinish={onFinish}>
				<Form.Item
					className={css.item}
					label="所在地区"
					name="districtName"
					initialValue=""
					rules={[{ required: true, message: '所在不能为空' }]}
				>
					<If condition={address !== null}>
						<Cascader options={address} />
					</If>
				</Form.Item>
				<Button type="link" htmlType="submit">
					提交
				</Button>
			</Form>
		</div>
	);
};
